package com.itheima.demo1Exception;

public class ExceptionDemo2 {
    public static void main(String[] args) {
        try {
            System.out.println(div(10,0));
            System.out.println("打印成功");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("打印失败");
        }
        System.out.println("程序继续运行");
    }
    public static int div(int a,int b) throws Exception {
        if(b==0){
            throw new Exception("除数不能为0");
        }
        int result=a/b;
        return result;
    }
}
